//
//  Model_QuestionComments.m
//  KWNLaywerClient
//
//  Created by 孔六五 on 15/1/16.
//  Copyright (c) 2015年 张明磊. All rights reserved.
//

#import "Model_QuestionComments.h"

@implementation Model_QuestionComments

- (void)getQuestionCommentWithDic:(NSDictionary *)dic
{
    NSString *adopt_ = [dic objectForKey:@"automatic_adopt"];
    NSString *time_ = [dic objectForKey:@"comment_time"];
    NSString *content_ = [dic objectForKey:@"content"];
    NSString *fuwu_ = [dic objectForKey:@"fuwu_fraction"];
    NSString *xy_ = [dic objectForKey:@"xy_fraction"];
    NSString *zy_ = [dic objectForKey:@"zy_fraction"];
    
    if(adopt_ && ![adopt_ isKindOfClass:[NSNull class]]){
        self.string_adopt = adopt_;
    }
    if(time_ && ![time_ isKindOfClass:[NSNull class]]){
        self.string_time = time_;
    }
    if(content_ && ![content_ isKindOfClass:[NSNull class]]){
        self.string_content = content_;
    }
    if(fuwu_ && ![adopt_ isKindOfClass:[NSNull class]]){
        self.string_fuwu = fuwu_;
    }
    if(xy_ && ![xy_ isKindOfClass:[NSNull class]]){
        self.string_xy = xy_;
    }
    if(zy_ && ![zy_ isKindOfClass:[NSNull class]]){
        self.string_zy = zy_;
    }

    //height(待处理)
    CGFloat height = 0;
    height = 10 + 20 + 10;                    //10时间label与cell上边界距离 20(显示时间高度) 第二个10 时间lebel与之下控件的间隔
    
    height = height + 20 * 3 + 10 * 2 + 10 + 3*2;  //每个评论点20高度 离气泡上下间隔各10 10与之下的控件间隔或者cell的间隔
    
    if(self.string_content && self.string_content.length>0)
    {
        CGSize commentSize = [UIUtils cgrectFor:self.string_content withFont:FontOfQuestionList labWidth:WidthMaxOfMessageImage - 25 - 33 - 5];      //-25前端气泡间隔15 后端气泡间隔10 20奖章20宽 奖章与label间隔5
        self.qCWidth_label = commentSize.width;
        if (commentSize.height >= HeightOfMedal) {                             //30奖章高度
            
            if (commentSize.height + 10 * 2>WidthOfHead + 30) {      //WidthOfHead头像高度 30名字lebel高度
                height = height + commentSize.height + 10*2 + 10;             //10*2label与气泡的间隔 10与之下控件的间隔或者cell的间隔
            }
            else
            {
                height = height + WidthOfHead + 30 + 10;                     //10与之下控件的间隔或者
            }
        }
        else
        {
            if (HeightOfMedal + 10 * 2>WidthOfHead + 30) {      //WidthOfHead头像高度 30名字lebel高度
                height = height + HeightOfMedal + 10*2 + 10;             //10*2label与气泡的间隔 10与之下控件的间隔或者cell的间隔
            }
            else
            {
                height = height + WidthOfHead + 30 + 10;                     //10与之下控件的间隔或者cell的间隔
            }
        }
    }
    else
    {
        self.qCWidth_label = 0;

        if (HeightOfMedal + 10 * 2>WidthOfHead + 30) {      //WidthOfHead头像高度 30名字lebel高度
            height = height + HeightOfMedal + 10*2 + 10;             //10*2奖章与气泡的间隔 10与之下控件的间隔或者cell的间隔
        }
        else
        {
            height = height + WidthOfHead + 30 + 10;                     //10与之下控件的间隔或者cell的间隔
        }

    }
    
    self.qCHeight = height;
    
}

@end
